* s~\t+$~~
[lhc/web/wiklou.git] / maintenance / dumpTextPass.php
index c81abba..5a3e11a 100644 (file)
@@ -32,33 +32,33 @@ require_once( 'maintenance/backup.inc' );
 
 class TextPassDumper extends BackupDumper {
        var $prefetch = null;
-       
+
        function dump() {
                # This shouldn't happen if on console... ;)
                header( 'Content-type: text/html; charset=UTF-8' );
-               
+
                # Notice messages will foul up your XML output even if they're
                # relatively harmless.
 //             ini_set( 'display_errors', false );
-               
+
                $this->startTime = wfTime();
-               
+
                $this->db =& $this->backupDb();
                $this->maxCount = $this->db->selectField( 'page', 'MAX(page_id)', '', 'BackupDumper::dump' );
                $this->startTime = wfTime();
-               
+
                $this->egress = new ExportProgressFilter( $this->sink, $this );
 
                $input = fopen( "php://stdin", "rt" );
                $result = $this->readDump( $input );
-               
+
                if( WikiError::isError( $result ) ) {
                        $this->progress( $result->getMessage() );
                }
-               
+
                $this->report( true );
        }
-       
+
        function processOption( $opt, $val, $param ) {
                if( $opt == 'prefetch' ) {
                        require_once 'maintenance/backupPrefetch.inc';
@@ -78,7 +78,7 @@ class TextPassDumper extends BackupDumper {
                        $this->prefetch = new BaseDump( $filename );
                }
        }
-       
+
        function readDump( $input ) {
                $this->buffer = "";
                $this->openElement = false;
@@ -87,13 +87,13 @@ class TextPassDumper extends BackupDumper {
                $this->lastName = "";
                $this->thisPage = 0;
                $this->thisRev = 0;
-               
+
                $parser = xml_parser_create( "UTF-8" );
                xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, false );
-               
+
                xml_set_element_handler( $parser, array( &$this, 'startElement' ), array( &$this, 'endElement' ) );
                xml_set_character_data_handler( $parser, array( &$this, 'characterData' ) );
-               
+
                $offset = 0; // for context extraction on error reporting
                $bufferSize = 512 * 1024;
                do {
@@ -106,7 +106,7 @@ class TextPassDumper extends BackupDumper {
                } while( $chunk !== false && !feof( $input ) );
                xml_parser_free( $parser );
        }
-       
+
        function getText( $id ) {
                if( isset( $this->prefetch ) ) {
                        $text = $this->prefetch->prefetch( $this->thisPage, $this->thisRev );
@@ -123,11 +123,11 @@ class TextPassDumper extends BackupDumper {
                $normalized = UtfNormal::cleanUp( $stripped );
                return $normalized;
        }
-       
+
        function startElement( $parser, $name, $attribs ) {
                $this->clearOpenElement( null );
                $this->lastName = $name;
-               
+
                if( $name == 'revision' ) {
                        $this->state = $name;
                        $this->egress->writeOpenPage( null, $this->buffer );
@@ -140,7 +140,7 @@ class TextPassDumper extends BackupDumper {
                                $this->atStart = false;
                        }
                }
-               
+
                if( $name == "text" && isset( $attribs['id'] ) ) {
                        $text = $this->getText( $attribs['id'] );
                        $this->openElement = array( $name, array( 'xml:space' => 'preserve' ) );
@@ -151,14 +151,14 @@ class TextPassDumper extends BackupDumper {
                        $this->openElement = array( $name, $attribs );
                }
        }
-       
+
        function endElement( $parser, $name ) {
                if( $this->openElement ) {
                        $this->clearOpenElement( "" );
                } else {
                        $this->buffer .= "</$name>";
                }
-               
+
                if( $name == 'revision' ) {
                        $this->egress->writeRevision( null, $this->buffer );
                        $this->buffer = "";
@@ -172,7 +172,7 @@ class TextPassDumper extends BackupDumper {
                        $this->buffer = "";
                }
        }
-       
+
        function characterData( $parser, $data ) {
                $this->clearOpenElement( null );
                if( $this->lastName == "id" ) {
@@ -184,7 +184,7 @@ class TextPassDumper extends BackupDumper {
                }
                $this->buffer .= htmlspecialchars( $data );
        }
-       
+
        function clearOpenElement( $style ) {
                if( $this->openElement ) {
                        $this->buffer .= wfElement( $this->openElement[0], $this->openElement[1], $style );